<?php
include_once("php/dbconfig.php");
include_once("php/functions.php");


function getCalendarByRange($id) {
    try {
        $db = new DBConnection();
        $db->getConnection();
        $sql = "SELECT  `event`.`eid`, `event`.`subject`,`event`.`start_time`,`event`.`end_time`, 
                    `event`.`is_allday_event`,`event`.`color`,`event`.`detail_url`,`event`.`festival`,`event`.`flash_paths`,
                    `event`.`description`,`event`.`picture_paths`,`event`.`vid`,`event`.`etid`,`event`.`commercial_control`,
                    `event`.`uid`,`venue`.`telephones`,`venue`.`urls`,`venue`.`address_zh_hk`,
                    `venue`.`contact_person`,`venue`.`cid`,`venue`.`name_zh_hk` AS `vname_zh_hk`,
                    `event_type`.`name_zh_hk` AS `etname_zh_hk`,`city`.`name_zh_hk` AS `cname_zh_hk`
            FROM `event` INNER JOIN `venue` ON `event`.`vid` = `venue`.`vid`
            INNER JOIN `event_type` ON `event`.`etid` = `event_type`.`etid`
            INNER JOIN `city` ON `venue`.`cid` = `city`.`cid`
            WHERE `event`.`eid` = " . $id;
        $handle = mysql_query($sql);
        //echo $sql;
        $row = mysql_fetch_object($handle);
    } catch (Exception $e) {
        
    }
    return $row;
}

if ($_GET["id"]) {
    $event = getCalendarByRange($_GET["id"]);
}
?>

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" >

    <head>    
        <meta http-equiv="Content-Type" content="text/html;charset=UTF-8"/>
        <link href="css/main.css" rel="stylesheet" type="text/css" />
        <!--
        <script src="src/jquery.js" type="text/javascript"></script>
        <script src="src/Plugins/wdCalendar_lang_HK.js" type="text/javascript"></script>
        <script src="src/Plugins/jquery.datepicker.js" type="text/javascript"></script>
        -->
    </head>
    
    <body>
        <div class="infocontainer">
            
            <?php
                if(isset($event)&& !empty($event->festival)){
                    echo '<label><span>所屬節目: </span>';
                    echo $event->festival;
                    echo '</label><br/>';
                }
                
                echo '<label><span>活動名稱:&nbsp;&nbsp;</span>';
                echo $event->subject;
                echo '</label><br/>';
                
                echo '<label><span>日&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;期:&nbsp;&nbsp;</span>';
                echo $event->start_time;
                echo '&nbsp;&nbsp;至&nbsp;&nbsp;';
                echo $event->end_time;
                echo '</label><br/>';
                
                echo '<label><span>城&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;市:&nbsp;&nbsp;</span>';
                echo $event->cname_zh_hk;
                echo '</label><br/>';
                
                echo '<label><span>場&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;地:&nbsp;&nbsp;</span>';
                echo $event->vname_zh_hk;
                echo '</label><br/>';
           
                echo '<label><span>地&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;址:&nbsp;&nbsp;';
                echo $event->address_zh_hk;
                echo '</label><br/>';
                
                echo '<label><span>類&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;型:&nbsp;&nbsp;</span>';
                echo $event->etname_zh_hk;
                echo '</label><br/>';
                
                
                 if(isset($event)&& !empty($event->urls)){
                    echo '<label><span>網&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;站:&nbsp;&nbsp;</span>';
                     echo '<a href="';
                    echo $event->urls;
                    echo '" target="_blank">';
                    echo $event->urls;
                    echo '</a>';
                    echo '</label><br/>';
                }
                
                echo '<label><span>延伸閱讀:&nbsp;&nbsp;</span>';
                echo $event->description;
                echo '</label><br/>';
                
                if(isset($event)&& !empty($event->detail_url)){
                    echo '<label class = "hrefhighlink"><span>延伸閱讀:&nbsp;&nbsp;</span>';
                    echo '<a href="';
                    echo $event->detail_url;
                    echo '" target="_blank">';
                    echo $event->detail_url;
                    echo '</a>';
                    echo '</label><br/>';
                }
                
                 if(isset($event)&& !empty($event->picture_paths)){
                      $paths = explode(";", $event->picture_paths);
                      if(!empty($paths[1])){
                          echo '<label><span>圖&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;片:&nbsp;&nbsp;</span>';
                          echo "<img src='";
                          echo $paths[1];
                          echo "' \/>";
                          echo '</label><br/>';
                      }
                      if(!empty($paths[2])){
                          echo '<label><span>圖&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;片:&nbsp;&nbsp;</span>';
                          echo "<img src='";
                          echo $paths[2];
                          echo "' \/>";
                          echo '</label><br/>';
                      }
                 }
                 
                if(isset($event)&& !empty($event->flash_paths)){
                    echo '<label><span>多媒體:&nbsp;&nbsp;&nbsp;&nbsp;</span>';
                    echo "<embed src='"; 
                    echo $event->flash_paths;
                    echo "' type=\"application/x-shockwave-flash\" wmode=\"transparent\">";
                    echo '</label><br/>';
                }
                
            ?>
            
        </div>
    </body>    
</html>    